@extends('admin.base')
    @section('content')
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            信息输出表
            <small>preview of simple tables</small>
          </h1>
          <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">标签信息</a></li>
            <li class="active">列表</li>
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
          <div class="row">
            <div class="col-md-12">
              <div class="box">
                <div class="box-header with-border">
                  <h3 class="box-title"><i class="fa fa-th"></i> 标签管理</h3>

                </div><!-- /.box-header -->
                <div class="box-body">
                  <table class="table table-bordered text-center">
                    <tr>
                      <th style="width:80px">id</th>
                      <th>折扣</th>
                      <th>评分</th>
                      <th>价格</th>
                      
                      <th style="width: 200px">操作</th>
                    </tr>
                    @foreach($list as $v)
                    <tr>
                      <td id="bjid">{{$v->id}}</td>
                      <td>{{$v->zhekou}}</td>
                      <td>{{$v->level}}</td>
                      <td>{{$v->newprice}}</td>
                      
                      <td>
						<button onclick="doDel({{$v->id}})" class="btn btn-xs btn-danger">删除</button>
						<!--<a href="{{url('admin/ctype')}}/{{$v->id}}/edit"><button class="btn btn-xs btn-primary" >编辑</button></a></td>--> 
						<button onclick="doEdit({{$v->id}})" class="btn btn-xs btn-primary" >编辑</button>
						<button onclick="loadAdd()" class="btn btn-xs btn-success" >添加</button>
						
					  </td>
                    </tr>
                    @endforeach
                  </table>
                </div><!-- /.box-body -->
				
			
              </div><!-- /.box -->
            </div><!-- /.col -->
          </div><!-- /.row -->
        </section><!-- /.content -->
        <form action="" style="display:none;" id="mydeleteform" method="post">
            <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
            <input type="hidden" name="_method" value="DELETE">
        </form>
		<form action="" style="display:none;" id="id" method="get">
            
        </form>
		
    @endsection
    @section("myscript")
	 <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
        <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="exampleModalLabel">New message</h4>
          </div>
          <div class="modal-body">
           <!-- 此处填充 -->
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            <button type="button" onclick="saveConfig()" class="btn btn-primary">提交</button>
          </div>
        </div>
      </div>
    </div>
      <script type="text/javascript">
			//执行删除
           function doDel(id){
				Modal.confirm({msg:'是否删除？'}).on(function (e){
					if(e){
						var form = document.getElementById("mydeleteform");
						form.action = "{{URL('/admin/label')}}/"+id;
						form.submit(); 
					}
				});
			}
			//加载添加表单
			function loadAdd(){
				$("#exampleModalLabel").html("添加商品类别");
				$("#exampleModal").modal("show");
            
				$.ajax({
					url:"{{URL('admin/label/create')}}",
					type:"get",
					dataType:"html",
					async:true,
					success:function(data){
					  $("#exampleModal .modal-body").html(data);   
					},
				 });
			
			}
			
			//提交信息
			 //保存类别信息
         function saveConfig(){
            
            $("#myaddform").submit();
            /*$.ajax({
                url:"{{url('admin/ctype')}}",
                type:"post",
                dataType:"html",
                data:$("#myaddform").serialize() ,
                async:true,
                success:function(data){
                    $('#exampleModal').modal('hide');
                    Modal.alert({msg:data,title: ' 信息提示',btnok: '确定',btncl:'取消'});
                    $("div.content-wrapper").html(data);
                },
             });
            */
        }
		//加载添加表单
			function doEdit(id){
				$("#exampleModalLabel").html("修改商品类别");
				$("#exampleModal").modal("show");
            
				$.ajax({
					url:"{{URL('admin/label')}}/"+id+"/edit",
					type:"get",
					dataType:"html",
					async:true,
					success:function(data){
					  $("#exampleModal .modal-body").html(data);   
					},
				 });
			
			}
			
			 function Change(id){
				$("#exampleModalLabel").html("");
				$("#exampleModal").modal("show");
            
				$.ajax({
					url:"{{URL('admin/aconfig')}}/"+id+"/edit",
					type:"get",
					dataType:"html",
					async:true,
					success:function(data){
					  $("#exampleModal .modal-body").html(data);   
					},
				 });
			
			}
		</script>
    @endsection